package com.rp.system.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rp.common.utils.RpUtil;
import com.rp.system.dao.LoginLogDao;
import com.rp.system.po.LoginLog;

@Service
@Transactional
public class LoginLogService {

	@Autowired
	private LoginLogDao loginLogDao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	
	public void addLoginLog(String ip, String username, String realname){
		LoginLog ll = new LoginLog();
		ll.setIp(ip);
		ll.setUsername(username);
		ll.setRealname(realname);
		ll.setCreateDate(RpUtil.getCurrentDatetime());
		loginLogDao.save(ll);
	}
	
	/**
	 * 删除所有日志记录
	 */
	public void removeAll(){
		jdbcTemplate.execute("DELETE FROM RP_SYSTEM_LOGINLOGS");
	}
	
	
	public LoginLogDao getLoginLogDao() {
		return loginLogDao;
	}
	
}
